package com.guchenbo.example.proxy;

import org.springframework.aop.framework.ProxyFactory;

public class AopDemo {
    public static void main(String[] args) {
        ProxyFactory proxyFactory = new ProxyFactory();

        proxyFactory.addAdvice(new LogInterceptor());

        proxyFactory.setInterfaces(EchoService.class.getInterfaces());
        proxyFactory.setTargetClass(EchoService.class);
//                proxyFactory.setTarget(new HelloServiceImpl());

        Object object = proxyFactory.getProxy();
        if (object instanceof EchoService) {
            object.hashCode();
            ((EchoService) object).echo("he");
        }
    }
}
